<template>
    <div style="height: 100%; width: 100%; position: relative">
        <div class="pagetop" :style="{ height: OtherShow ? '155px' : '95px' }">
            <div style="width: 100%">
                <div style="float: left; width: 100%">
                    <table style="font-size: 12px" class="table2style" border="0">
                        <tr>
                            <td align="right">
                                <el-dropdown @command="handleCommand" style="font-size: 12px">
                                    <u class="el-dropdown-link">
                                        {{ datename }}
                                    </u>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item command="生成日期">
                                            <font font-size="12px">生成日期</font>
                                        </el-dropdown-item>
                                        <el-dropdown-item command="接收日期">
                                            <font font-size="12px">接收日期</font>
                                        </el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </td>
                            <td>
                                <el-date-picker v-model="datetime1" type="date" align="right" value-format="yyyy-MM-dd 00:00:00" size="mini" placeholder="开始日期" :clearable="false" style="width: 100%"></el-date-picker>
                            </td>
                            <td style="text-align:center">至</td>
                            <td>
                                <el-date-picker v-model="datetime2" type="date" align="right" value-format="yyyy-MM-dd 23:59:59" size="mini" placeholder="结束日期" :clearable="false" style="width: 100%"></el-date-picker>
                            </td>
                            <td align="right">条码号</td>
                            <td>
                                <el-input v-model="barcode" size="mini" @keyup.enter.native="QueryMainthen()" ref="barcode"></el-input>
                            </td>
                            <td align="right">病人姓名</td>
                            <td>
                                <el-input v-model="patname" size="mini" style="width: 100%"></el-input>
                            </td>
                            <td align="right">病人类型</td>
                            <td>
                                <el-select v-model="pattype" size="mini" style="width: 100%" clearable>
                                    <el-option v-for="item in pattypes" :key="item.codeno" :value="item.codeno" :label="item.codena"></el-option>
                                </el-select>
                            </td>
                            <td align="right">申请医生</td>
                            <td>
                                <rm-ddl-common datatype="doctor" dataname="申请医生" v-model="reqdoc" size="mini" width="100%" @change="reqdocChange"></rm-ddl-common>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">申请状态</td>
                            <td >
                                <el-popover width="100%" trigger="click" placement="bottom">
                                    <div style="height: 300px">
                                        <div>
                                            <table class="table1style">
                                                <el-checkbox-group v-model="reqstat">
                                                    <tr v-for="(list, index) in reqstatOption" :key="index">
                                                        <td v-for="(item, sindex) in list" :key="sindex" style="text-align: left; width: 120px">
                                                            <el-checkbox :label="item.data" @change="handselect($event, item.data, 'reqstat')">{{ item.display }}</el-checkbox>
                                                        </td>
                                                    </tr>
                                                </el-checkbox-group>
                                            </table>
                                        </div>
                                        <hr />
                                        <div>
                                            <table class="table1style">
                                                <el-checkbox-group v-model="sourceflag">
                                                    <tr v-for="(list, index) in reqstatOption2" :key="index">
                                                        <td v-for="(item, sindex) in list" :key="sindex" style="text-align: left; width: 120px">
                                                            <el-checkbox :label="item.value" @change="handselect($event, item.value, 'sourceflag')">{{ item.label }}</el-checkbox>
                                                        </td>
                                                    </tr>
                                                </el-checkbox-group>
                                            </table>
                                        </div>
                                    </div>
                                    <el-input slot="reference" v-model="showstat" style="width: 100%; cursor: pointer" readonly placeholder="请选择过滤条件" clearable @clear="clear"></el-input>
                                </el-popover>
                            </td>
                            <td align="right">病历号</td>
                            <td>
                                <el-input v-model="patno" size="mini" style="width: calc(100% - 60px)" @keyup.enter.native="QueryMainthen()"></el-input>
                                <el-button style="margin-left: 4px" @click="BtnReadCard">读卡</el-button>
                            </td>
                            <td align="right">分单类别</td>
                            <td>
                                <!-- <rm-ddl-common datatype="reqgroup" dataname="分单类别" v-model="reqgroup" size="mini" width="100%"></rm-ddl-common> -->
                                <el-select v-model="reqgroup" @dblclick.native="popMultipleChk(reqgroup, 'reqgroup', reqgroupOption, '分单类别选择')" style="width: 100%" filterable clearable>
                                    <el-option v-for="(item, index) in reqgroupOption" :key="index" :value="item.data" :label="item.display"> </el-option>
                                </el-select>
                            </td>
                            <td align="right">标本类型</td>
                            <td>
                                <rm-ddl-common datatype="specimen" dataname="标本类型" v-model="specimencode" size="mini" width="100%" @change="specimenChange"></rm-ddl-common>
                            </td>
                            <td align="right">申请科室</td>
                            <td>
                                <rm-ddl-common datatype="dept" dataname="科室" v-model="reqdeptno" size="mini" width="100%" @change="reqdeptChange"></rm-ddl-common>
                            </td>
                             <td align="right">病人病区</td>
                            <td>
                                <rm-ddl-common datatype="ward" dataname="病区" v-model="reqwardno" size="mini" width="100%" @change="reqwardChange"></rm-ddl-common>
                            </td>
                        </tr>
                        <tr v-show="OtherShow">
                            <td align="right">申请项目</td>
                            <td colspan="3">
                                <!-- <rm-ddl-common datatype="reqitem" dataname="申请项目" v-model="reqitem" size="mini" width="100%"></rm-ddl-common> -->
                                <el-select v-model="reqitem" @dblclick.native="popMultipleChk(reqitem, 'reqitem', reqitemOption, '申请项目选择')" style="width: 100%" filterable clearable>
                                    <el-option v-for="(item, index) in reqitemOption" :key="index" :value="item.data" :label="item.display"> </el-option>
                                </el-select>
                            </td>
                            <td align="right">检验组</td>
                            <td>
                                <rm-ddl-common datatype="labgroup" dataname="检验工作组" v-model="txtlabgoup" width="100%" @change="labgroupChange"></rm-ddl-common>
                            </td>
                            <td align="right">送检医院</td>
                            <td>
                                <rm-ddl-common datatype="hospital" dataname="医院" v-model="hospcode" size="mini" width="100%" @change="hospChange"></rm-ddl-common>
                            </td>
                            <td align="right">执行科室</td>
                            <td>
                                <rm-ddl-common datatype="dept" dataname="科室" v-model="peformedeptno" size="mini" width="100%" @change="peformedeptChange"></rm-ddl-common>
                            </td>
                            <td align="right">病人床号</td>
                            <td>
                                <el-input v-model="bedno" size="mini"></el-input>
                            </td>
                            <!-- <td align="right">运输冷链ID</td>
                            <td>
                                <el-input v-model="transid" size="mini" style="width:100%"></el-input>
                            </td> -->
                        </tr>
                        <tr v-show="OtherShow">
                            <td align="right">预出报告时间</td>
                            <td>
                                <el-date-picker v-model="prerptdt1" type="date" align="right" value-format="yyyy-MM-dd 00:00:00" size="mini" placeholder="开始日期" style="width: 100%"></el-date-picker>
                            </td>
                            <td style="text-align:center">至</td>
                            <td>
                                <el-date-picker v-model="prerptdt2" type="date" align="right" value-format="yyyy-MM-dd 23:59:59" size="mini" placeholder="结束日期" style="width: 100%"></el-date-picker>
                            </td>
                            <td align="right">样本号</td>
                            <td>
                                <el-input v-model="sampleno" size="mini"></el-input>
                            </td>
                            <td align="right">报告日期</td>
                            <td>
                                <el-date-picker v-model="daterpt" type="date" align="right" value-format="yyyy-MM-dd" size="mini" placeholder="报告日期" style="width: 100%"></el-date-picker>
                            </td>
                            <!--
                            <td align="right">报告单元</td>
                            <td>
                                <rm-ddl-rptunit prgno="LIS430" defaultflag="" v-model="rptunit" size="mini" width="100%"></rm-ddl-rptunit>
                            </td>
                            -->
                            <td align="right">报告单元多选</td>
                            <td>
                                <rm-ddl-rptunit prgno="LIS430" :multiple_choice="true" v-model="sel_rptunitlist" clearable width="100%" @change="rptunitChange"></rm-ddl-rptunit>
                            </td>
                            <td colspan="2">
                                <el-checkbox v-model="reqgrouprepair"  style="float: left; padding: 0px;">检验组修复模式</el-checkbox>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" v-if="OtherShow">打印次数</td>
                            <td v-else></td>
                            <td v-if="OtherShow"><el-input v-model="printcount" size="mini" type="number" oninput="if(value < 0){ value = undefined}"></el-input></td>
                            <td v-else></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td colspan="4">
                                <div style="width: 100%; text-align: right">
                                    <table style="width: 100%">
                                        <tr>
                                            <td>
                                                <el-link :underline="false" @click="OtherShow = !OtherShow">{{ OtherShow ? "收起▲" : "展开▼" }}</el-link>
                                                <el-button icon="el-icon-search" type="primary" @click="QueryMainthen()">查询</el-button>
                                                <el-button icon="el-icon-print" @click="Reprint()">补打条码</el-button>
                                                <el-button @click="setExportColumn">导出列设置</el-button>
                                                <el-button icon="el-icon-download" @click="btnExport()">导出</el-button>
                                                <el-button @click="btnRptDelay()">报告延迟</el-button>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <div class="pagecenter" :style="{ top: OtherShow ? '160px' : '100px' }">
            <rm-layout-right splitcolor="#ffffff" :splitwidth="3" :fixsize="480" :minfixsize="100" ref="layoutright">
                <div style="height: 100%">
                    <vxe-table :data.sync="tableData" @current-change="DataSelect" :sort-config="{ trigger: 'cell' }" height="100%" highlight-current-row highlight-hover-row ref="table" resizable highlight-hover-column border show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" :loading="loading" size="mini" :cell-class-name="cellClassName">
                        <vxe-table-column type="index" title="NO." width="40px" align="center"></vxe-table-column>
                        <vxe-table-column type="selection" title="" width="40px" align="center"></vxe-table-column>
                        <vxe-table-column field="create_dt" title="创建时间" width="120px" align="center" sortable></vxe-table-column>
                        <!-- 病历号 姓名 申请项目列添加排序-->
                        <!-- <vxe-table-column field="pat_no" title="病历号" width="90px"></vxe-table-column> -->
                        <vxe-table-column field="pat_no" title="病历号" width="90px" sortable></vxe-table-column>
                        <!-- <vxe-table-column field="pat_name" title="姓名" width="50px" align="center"></vxe-table-column> -->
                        <vxe-table-column field="pat_name" title="姓名" width="50px" align="center" sortable></vxe-table-column>
                        <vxe-table-column field="barcode" title="条码号" width="100px"></vxe-table-column>
                        <vxe-table-column field="emer_flag" title="加急" width="40px" align="center" sortable>
                            <template v-slot="{ row }">
                                <span style="color: red" v-if="row.emer_flag == '1'">急</span>
                                <span v-else></span>
                            </template>
                        </vxe-table-column>
                        <!-- <vxe-table-column field="sample_items" title="申请项目" width="200px"></vxe-table-column> -->
                        <vxe-table-column field="sample_items" title="申请项目" width="260px" sortable></vxe-table-column>
                        <vxe-table-column field="amount" title="金额" width="40px" text-align="center" align="right"></vxe-table-column>
                        <vxe-table-column field="req_stat" title="状态" width="60px" align="center" :formatter="FormatData" sortable></vxe-table-column>
                        <vxe-table-column field="doctorname" title="申请医生" width="60px" align="center" sortable></vxe-table-column>
                        <vxe-table-column field="deptname" title="申请科室" width="120px" sortable></vxe-table-column>
                        <vxe-table-column field="cp_sampleno" title="标本号" width="100px" sort-width="20" sortable></vxe-table-column>
                        <vxe-table-column field="req_bedno" title="床号" width="30px" sortable></vxe-table-column>
                        <vxe-table-column field="specimen_codename" title="标本类型" width="60px" sortable></vxe-table-column>
                        <vxe-table-column field="req_groupna" title="分单类别" width="100px" sortable></vxe-table-column>
                        <vxe-table-column field="pat_sexname" title="性别" width="30px" align="center" sortable></vxe-table-column>
                        <vxe-table-column field="pat_agestr" title="年龄" width="50px" align="center" sortable></vxe-table-column>
                        <vxe-table-column field="labadd" title="实验室增加标志" width="60px" align="center">
                            <template v-slot="{ row }">
                                <el-checkbox v-model="row.labadd" disabled></el-checkbox>
                            </template>
                        </vxe-table-column>
                        <vxe-table-column field="create_username" title="创建人" width="60px" align="center" ></vxe-table-column>
                        <vxe-table-column field="print_dt" title="打印日期" width="120px" align="center"></vxe-table-column>
                        <vxe-table-column field="print_username" title="打印人" width="60px" align="center" ></vxe-table-column>
                        <vxe-table-column field="print_count" title="打印次数" width="60px" align="right" header-align="center"></vxe-table-column>
                        <vxe-table-column field="sampled_dt" title="采样时间" width="120px" align="center"></vxe-table-column>
                        <vxe-table-column field="sampled_username" title="采样人" width="60px" align="center" ></vxe-table-column>
                        <vxe-table-column field="recieve_dt" title="接收时间" width="120px" align="center"></vxe-table-column>
                        <vxe-table-column field="recieve_username" title="接收人" width="100px" align="center"></vxe-table-column>
                        <vxe-table-column field="req_dt" title="申请日期" width="120px" align="center"></vxe-table-column>
                        <vxe-table-column field="prereport_dt" title="预出报告时间" width="120px"></vxe-table-column>
                        <vxe-table-column field="prereport_comm" title="预出报告领取提示" width="100px"></vxe-table-column>
                        <vxe-table-column field="cp_tatreq2smpd" title="申请-采样(分钟)" width="100px" align="center"></vxe-table-column>
                        <vxe-table-column field="cp_tatsmpd2send" title="采样-接收(分钟)" width="100px" align="center"></vxe-table-column>
                        <vxe-table-column field="cp_tatsend2report" title="接收-报告(分钟)" width="100px" align="center"></vxe-table-column>
                        <vxe-table-column field="cp_tatreq2report" title="申请-报告(分钟)" width="100px" align="center"></vxe-table-column>
                        <vxe-table-column field="cp_tatsmpd2report" title="采样-报告(分钟)" width="100px" align="center"></vxe-table-column>
                        <vxe-table-column field="cp_tatreq2send" title="申请-接收(分钟)" width="100px" align="center"></vxe-table-column>
                        <vxe-table-column field="pat_diag" title="临床诊断" width="100px"></vxe-table-column>
                        <vxe-table-column field="pat_id" title="病人ID号" width="100px"></vxe-table-column>
                        <vxe-table-column field="perform_deptname" title="执行科室" width="100px"></vxe-table-column>
                        <vxe-table-column field="inp_date" title="入院日期" width="100px"></vxe-table-column>
                        <vxe-table-column field="send_dt" title="送出时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="send_username" title="送出人" width="100px"></vxe-table-column>
                        <vxe-table-column field="recieve_host" title="接收电脑" width="100px"></vxe-table-column>
                        <vxe-table-column field="prereport_dt1" title="预出报告时间1" width="100px"></vxe-table-column>
                        <vxe-table-column field="charge_username" title="计价人" width="100px"></vxe-table-column>
                        <vxe-table-column field="charge_dt" title="计价时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="amount" title="实收总金额" width="100px" text-align="center" align="right"></vxe-table-column>
                        <vxe-table-column field="charge_flag" title="收费标志" width="100px"></vxe-table-column>
                        <vxe-table-column field="test_dt" title="上机时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="test_username" title="上机人" width="100px"></vxe-table-column>
                        <vxe-table-column field="report_dt" title="报告时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="report_username" title="检验医生姓名" width="100px"></vxe-table-column>
                        <vxe-table-column field="rechk_username" title="核对医生姓名" width="100px"></vxe-table-column>
                        <vxe-table-column field="alter_flag" title="警告标志" width="60px"></vxe-table-column>
                        <!-- <vxe-table-column field="saleman" title="销售人" width="100px" :formatter="formatFun"></vxe-table-column> -->
                        <vxe-table-column field="pat_cardno" title="就诊卡号" width="100px"></vxe-table-column>
                        <vxe-table-column field="req_comm" title="医生备注" width="150px"></vxe-table-column>
                        <vxe-table-column field="pat_birth" title="病人生日" width="100px"></vxe-table-column>
                        <vxe-table-column field="pat_ageyear" title="年龄岁数" width="100px"></vxe-table-column>
                        <vxe-table-column field="inp_id" title="住院标识" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_diag_icd" title="诊断的ICD10编码" width="100px"></vxe-table-column>
                        <vxe-table-column field="pat_address" title="地址" width="100px"></vxe-table-column>
                        <vxe-table-column field="pat_nation" title="国籍" width="100px"></vxe-table-column>
                        <vxe-table-column field="pat_idcardno" title="身份证号护照号" width="140px"></vxe-table-column>
                        <vxe-table-column field="pat_phone" title="联系电话" width="100px"></vxe-table-column>
                        <vxe-table-column field="charge_typeno" title="收费类型" width="100px"></vxe-table-column>
                        <vxe-table-column field="req_wardname" title="申请病区" width="100px"></vxe-table-column>
                        <vxe-table-column field="secrecy" title="加密" width="60px"></vxe-table-column>
                        <vxe-table-column field="original_reqno" title="原始申请单号" width="100px"></vxe-table-column>
                        <vxe-table-column field="reqtype" title="申请业务类别" width="100px" :formatter="formatFun"></vxe-table-column>
                        <vxe-table-column field="hospcode" title="送检医院" width="100px" :formatter="formatFun"></vxe-table-column>
                        <vxe-table-column field="pat_hospcode" title="病人所属医院" width="100px" :formatter="formatFun"></vxe-table-column>
                        <vxe-table-column field="pat_typecodename" title="病人类型" width="100px"></vxe-table-column>
                        <vxe-table-column field="pat_height" title="身高" width="100px"></vxe-table-column>
                        <vxe-table-column field="weight" title="体重" width="100px"></vxe-table-column>
                        <vxe-table-column field="abo_bldtype" title="ABO血型" width="100px"></vxe-table-column>
                        <vxe-table-column field="rh_bldtype" title="RH血型" width="100px"></vxe-table-column>
                        <vxe-table-column field="req_bedseq" title="床号序号" width="100px"></vxe-table-column>
                        <vxe-table-column field="other_stat" title="备用标志" width="100px"></vxe-table-column>
                        <vxe-table-column field="sample_detail" title="标本备注说明" width="100px"></vxe-table-column>
                        <vxe-table-column field="req_reason" title="送检目的" width="100px"></vxe-table-column>
                        <vxe-table-column field="master_barcode" title="主申请号" width="100px"></vxe-table-column>
                        <vxe-table-column field="multi_seq" title="多条码序号" width="100px"></vxe-table-column>
                        <vxe-table-column field="reqsource" title="申请单来源" width="100px" :formatter="formatFun"></vxe-table-column>
                        <vxe-table-column field="newbldflag" title="新输血系统生成" width="100px"></vxe-table-column>
                        <vxe-table-column field="pregnancy_type" title="单胎/多胎妊娠" width="100px"></vxe-table-column>
                        <vxe-table-column field="pregnancy_weeks" title="孕周" width="100px"></vxe-table-column>
                        <vxe-table-column field="pregnancy_way" title="受孕方式" width="100px"></vxe-table-column>
                        <vxe-table-column field="samplevol" title="样本体积" width="100px"></vxe-table-column>
                        <vxe-table-column field="symptom" title="症状描述" width="100px"></vxe-table-column>
                        <vxe-table-column field="lmp" title="末次月经" width="100px"></vxe-table-column>
                        <vxe-table-column field="physicycle" title="生理周期" width="100px"></vxe-table-column>
                        <vxe-table-column field="chargefailcnt" title="计价失败次数" width="100px"></vxe-table-column>
                        <vxe-table-column field="chargefailmsg" title="计价失败原因" width="100px"></vxe-table-column>
                        <vxe-table-column field="chargeex_flag" title="需补计价标志" width="100px"></vxe-table-column>
                        <vxe-table-column field="sampled_chkuser" title="采样核对者" width="100px"></vxe-table-column>
                        <vxe-table-column field="send_user1name" title="送达护工" width="100px" ></vxe-table-column>
                        <vxe-table-column field="send_dt1" title="护工送到时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="recieve1_dt" title="工作组接收时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="recieve1_user" title="工作组接收用户" width="100px"></vxe-table-column>
                        <vxe-table-column field="cancel_dt" title="作废时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="cancel_username" title="作废用户" width="100px"></vxe-table-column>
                        <vxe-table-column field="reject_dt" title="退回时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="reject_username" title="退回用户" width="100px"></vxe-table-column>
                        <vxe-table-column field="reject_reason" title="退回原因" width="100px"></vxe-table-column>
                        <vxe-table-column field="reject_count" title="退回次数" width="100px"></vxe-table-column>
                        <vxe-table-column field="report_id" title="报告单ID" width="100px"></vxe-table-column>
                        <vxe-table-column field="inlib_status" title="入库状态" width="100px"></vxe-table-column>
                        <vxe-table-column field="library_id" title="所在库位ID" width="100px"></vxe-table-column>
                        <vxe-table-column field="collectbarcode" title="采样回单条码" width="100px"></vxe-table-column>
                        <vxe-table-column field="report_dt1" title="首次报告时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="labgroupid" title="签收工作组" width="100px" :formatter="formatFun"></vxe-table-column>
                        <vxe-table-column field="discard_dt" title="遗弃时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="discard_username" title="遗弃人" width="100px"></vxe-table-column>
                        <vxe-table-column field="transportid" title="运输冷链ID" width="100px"></vxe-table-column>
                        <vxe-table-column field="recieveaddr" title="签收点" width="100px"></vxe-table-column>
                        <vxe-table-column field="packagebarcode" title="打包条码" width="100px"></vxe-table-column>
                        <vxe-table-column field="flag_fh" title="是否已复核" width="100px"></vxe-table-column>
                        <vxe-table-column field="flag_cy" title="是否已采样" width="100px"></vxe-table-column>
                        <vxe-table-column field="flag_sc" title="是否已送出" width="100px"></vxe-table-column>
                        <!-- <vxe-table-column field="rowversion" title="时间戳" width="100px"></vxe-table-column> -->
                        <vxe-table-column :key="item.field" :field="item.field" :title="item.title" v-for="item in AliasTableColumn" align="center" :width="item.width" sortable></vxe-table-column>
                    </vxe-table>
                    <div class="fixtotal">
                        <div style="width: 100%; background-color: white; text-align: right">
                                <span style="color: blue">合计: {{ Counts }} 条结果</span>
                            </div>
                        </div>
                </div>
                <template v-slot:fix>
                    <rm-layout-top splitcolor="white" :splitwidth="5" :fixsize="200">
                        <div style="height: 100%">
                            <vxe-table :data.sync="tableDatalog" :loading="loadinglog" :tree-config="{ children: 'children', expandAll: false }" :select-config="{ labelField: 'log_content' }" :fit="false" @cell-dblclick="LogDblClick" :cell-class-name="ColumnClassName" height="auto" highlight-current-row highlight-hover-row resizable header-align="center" show-overflow="tooltip" show-header-overflow="tooltip" size="mini" border stripe column-width="100px" ref="tablelog">
                                <!-- <vxe-table-column field="reportid" title="报告ID" width="120px" align="center" tree-node></vxe-table-column> -->
                                <vxe-table-column field="log_date" title="操作日期" width="120px" align="center"></vxe-table-column>
                                <vxe-table-column field="trans_type" title="操作类型" width="80px" align="center" :formatter="['formatSelectList', reqstatOptiontable]"></vxe-table-column>
                                <vxe-table-column field="log_content" title="操作内容" width="220px" tree-node>
                                    <template v-slot="{ row }">
                                        <div style="max-width: 180px; display: inline-block">{{ row.log_content }}</div>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column field="username" title="操作者" width="100px" align="center"></vxe-table-column>
                                <vxe-table-column field="ref_user" title="相关人" width="100px"></vxe-table-column>
                                <vxe-table-column field="labgroupid" title="工作组" width="100px"></vxe-table-column>
                                <vxe-table-column field="computer_name" title="操作时机器名" width="100px">
                                    <template v-slot="{ row }">
                                        <span style="color:blue;">{{row.computer_name}}</span>
                                        <i class="el-icon-refresh" @click="repalceComputerName(row)"></i>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column field="mac_address" title="操作时机器MAC" width="100px"></vxe-table-column>
                                <vxe-table-column field="syncflag" title="同步HIS标志" width="100px"></vxe-table-column>
                                <vxe-table-column field="synctime" title="同步时间" width="100px"></vxe-table-column>
                                <vxe-table-column field="syncerrtext" title="同步失败信息" width="100px"></vxe-table-column>
                            </vxe-table>
                        </div>
                        <template v-slot:fix>
                            <div style="height: 100%" v-show="!showmix">
                                <vxe-table :data.sync="tableDatareq" :loading="loadingreq" height="auto" highlight-current-row highlight-hover-row resizable header-align="center" show-overflow="tooltip" show-header-overflow="tooltip" size="mini" border stripe column-width="100px" ref="tablereq">
                                    <vxe-table-column field="req_itemname" title="项目名称" width="160px"></vxe-table-column>
                                    <vxe-table-column field="item_price" title="实际价格" width="100px" align="right" header-align="center"></vxe-table-column>
                                    <vxe-table-column field="qty" title="数量" width="80px" align="right" header-align="center"></vxe-table-column>
                                    <vxe-table-column field="amount" title="金额" width="100px" text-align="center" align="right" header-align="center"></vxe-table-column>
                                    <vxe-table-column field="seq" title="序号" width="60px"></vxe-table-column>
                                    <vxe-table-column field="base_price" title="基础价格" width="80px"></vxe-table-column>
                                    <vxe-table-column field="req_itemcode" title="项目代码" width="100px"></vxe-table-column>
                                    <vxe-table-column field="his_itemcode" title="HIS项目代码" width="100px"></vxe-table-column>
                                    <vxe-table-column field="his_recordid" title="HIS记录号" width="100px"></vxe-table-column>
                                    <vxe-table-column field="parent_itemcode" title="上级项目" width="100px"></vxe-table-column>
                                    <vxe-table-column field="combitemna" title="所属组合项目简称" width="100px"></vxe-table-column>
                                    <vxe-table-column field="stat_flag" title="统计标志" width="100px"></vxe-table-column>
                                    <vxe-table-column field="other_flag" title="其它标志" width="100px"></vxe-table-column>
                                    <vxe-table-column field="status" title="状态" width="80px"></vxe-table-column>
                                    <vxe-table-column field="reportid" title="报告ID" width="100px"></vxe-table-column>
                                    <vxe-table-column field="lab_add" title="实验室新增" width="80px"></vxe-table-column>
                                    <vxe-table-column field="add_dt" title="新增时间" width="100px"></vxe-table-column>
                                    <vxe-table-column field="add_user" title="新增人" width="100px"></vxe-table-column>
                                    <vxe-table-column field="req_groupid" title="分单类别ID" width="100px"></vxe-table-column>
                                    <vxe-table-column field="his_refcol1" title="HIS表相关字段1" width="100px"></vxe-table-column>
                                    <vxe-table-column field="his_refcol2" title="HIS表相关字段2" width="100px"></vxe-table-column>
                                    <vxe-table-column field="his_refcol3" title="HIS表相关字段3" width="100px"></vxe-table-column>
                                    <vxe-table-column field="emer_flag" title="急诊标志" width="100px"></vxe-table-column>
                                    <vxe-table-column field="charge_flag" title="计价标志" width="100px"></vxe-table-column>
                                    <vxe-table-column field="hospreqitemcode" title="外送医院项目代码" width="100px"></vxe-table-column>
                                </vxe-table>
                            </div>
                            <el-tabs v-model="tabvalue" style="height: 100%" type="border-card" v-show="showmix">
                                <el-tab-pane label="申请单明细" name="1" key="1" class="Listclass">
                                    <div style="height: 100%">
                                        <vxe-table :data.sync="tableDatareq" :loading="loadingreq" height="auto" highlight-current-row highlight-hover-row resizable header-align="center" show-overflow="tooltip" show-header-overflow="tooltip" size="mini" border stripe column-width="100px" ref="tablereq">
                                            <vxe-table-column field="req_itemname" title="项目名称" width="160px"></vxe-table-column>
                                            <vxe-table-column field="item_price" title="实际价格" width="100px" align="right" header-align="center"></vxe-table-column>
                                            <vxe-table-column field="qty" title="数量" width="80px" align="right" header-align="center"></vxe-table-column>
                                            <vxe-table-column field="amount" title="金额" width="100px" text-align="center" align="right" header-align="center"></vxe-table-column>
                                            <vxe-table-column field="seq" title="序号" width="60px"></vxe-table-column>
                                            <vxe-table-column field="base_price" title="基础价格" width="80px"></vxe-table-column>
                                            <vxe-table-column field="req_itemcode" title="项目代码" width="100px"></vxe-table-column>
                                            <vxe-table-column field="his_itemcode" title="HIS项目代码" width="100px"></vxe-table-column>
                                            <vxe-table-column field="his_recordid" title="HIS记录号" width="100px"></vxe-table-column>
                                            <vxe-table-column field="parent_itemcode" title="上级项目" width="100px"></vxe-table-column>
                                            <vxe-table-column field="combitemna" title="所属组合项目简称" width="100px"></vxe-table-column>
                                            <vxe-table-column field="stat_flag" title="统计标志" width="100px"></vxe-table-column>
                                            <vxe-table-column field="other_flag" title="其它标志" width="100px"></vxe-table-column>
                                            <vxe-table-column field="status" title="状态" width="80px"></vxe-table-column>
                                            <vxe-table-column field="reportid" title="报告ID" width="100px"></vxe-table-column>
                                            <vxe-table-column field="lab_add" title="实验室新增" width="80px"></vxe-table-column>
                                            <vxe-table-column field="add_dt" title="新增时间" width="100px"></vxe-table-column>
                                            <vxe-table-column field="add_user" title="新增人" width="100px"></vxe-table-column>
                                            <vxe-table-column field="req_groupid" title="分单类别ID" width="100px"></vxe-table-column>
                                            <vxe-table-column field="his_refcol1" title="HIS表相关字段1" width="100px"></vxe-table-column>
                                            <vxe-table-column field="his_refcol2" title="HIS表相关字段2" width="100px"></vxe-table-column>
                                            <vxe-table-column field="his_refcol3" title="HIS表相关字段3" width="100px"></vxe-table-column>
                                            <vxe-table-column field="emer_flag" title="急诊标志" width="100px"></vxe-table-column>
                                            <vxe-table-column field="charge_flag" title="计价标志" width="100px"></vxe-table-column>
                                            <vxe-table-column field="hospreqitemcode" title="外送医院项目代码" width="100px"></vxe-table-column>
                                        </vxe-table>
                                    </div>
                                </el-tab-pane>
                                <el-tab-pane label="混样数据" name="2" key="2" class="Listclass">
                                    <div style="height: 100%">
                                        <vxe-table :data.sync="tableDataMix" :loading="loadingmix" height="auto" highlight-current-row highlight-hover-row resizable header-align="center" show-overflow="tooltip" show-header-overflow="tooltip" size="mini" border stripe column-width="100px" ref="tablemix">
                                            <vxe-table-column type="index" title=" 序号" width="40" align="center"></vxe-table-column>
                                            <vxe-table-column field="barcode" sortable title="条码号" width="90"></vxe-table-column>
                                            <vxe-table-column field="pat_name" sortable title="姓名" width="80" align="center"></vxe-table-column>
                                            <vxe-table-column field="pat_sexname" sortable title="性别" width="40" align="center"></vxe-table-column>
                                            <vxe-table-column field="pat_agestr" sortable title="年龄" width="40"></vxe-table-column>
                                            <vxe-table-column field="pat_no" title="病人号" width="80"></vxe-table-column>
                                            <vxe-table-column field="pat_idcardno" title="身份证号" width="80"></vxe-table-column>
                                            <vxe-table-column field="pat_phone" title="联系电话" width="80"></vxe-table-column>
                                            <vxe-table-column field="add_dt" sortable title="混样时间" width="120"></vxe-table-column>
                                            <vxe-table-column field="add_username" sortable title="混样人" width="80" align="center"></vxe-table-column>
                                            <vxe-table-column field="specimen_name" sortable title="标本类型" width="80"></vxe-table-column>
                                            <vxe-table-column field="sample_items" sortable title="项目描述" width="120"></vxe-table-column>
                                            <vxe-table-column field="req_docname" title="申请医生" width="120"></vxe-table-column>
                                            <vxe-table-column field="req_deptname" title="申请科室" width="130" header-align="center"></vxe-table-column>
                                            <vxe-table-column field="pat_address" title="病人联系地址" width="180" header-align="center"></vxe-table-column>
                                            <vxe-table-column field="pat_cardno" title="就诊卡号" width="100" header-align="center"></vxe-table-column>
                                            <vxe-table-column field="inp_id" title="住院标识" width="100" header-align="center"></vxe-table-column>
                                            <vxe-table-column field="pat_id" title="病人唯一号" width="100" header-align="center"></vxe-table-column>
                                        </vxe-table>
                                    </div>
                                </el-tab-pane>
                            </el-tabs>
                        </template>
                    </rm-layout-top>
                </template>
            </rm-layout-right>

            <!--导出-->
            <el-dialog title="提示" :visible.sync="dialogExport" width="580px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" ref="refdialogExport">
                <div>选择是则导出结果信息，选择否则导出结果明细信息，选择取消则取消本次导出！</div>
                <span slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="exportOperate(1)">是</el-button>
                    <el-button type="primary" @click="exportOperate(2)">否</el-button>
                    <el-button @click="dialogExport = false">取 消</el-button>
                </span>
            </el-dialog>

            <!--延迟报告-->
            <!-- <el-dialog title="报告延时发放" :visible.sync="dialogRptDelay" width="580px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" ref="refdialogRptDelay">
                <div style="height:200px">
                    <div> 请输入报告发放延时时间（单位：小时）：<el-input v-model="Delay.hour" type="number" style="width:100px" ref="refhour"></el-input>
                    </div>
                    <div>报告延时原因：</div>
                    <div>
                        <el-input v-model="Delay.content" type="textarea" :rows="7"></el-input>
                    </div>
                </div>
                <span slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="RptDelaySave">确认</el-button>
                    <el-button @click="dialogRptDelay = false">取 消</el-button>
                </span>
            </el-dialog> -->
            <!--报告延时发放加入组件-->
            <el-dialog title="报告延时发放" :visible.sync="dialogRptDelay" width="580px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" ref="refdialogRptDelay">
                <rm-rptdelay :barcodes="delay.barcodes" ref="refrptdelay" :key="delay.delaykey" @change="RptDelayChange"></rm-rptdelay>
            </el-dialog>
            <el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialogDetailVisible" title="检验报告修改详细内容" top="5vh" width="800px">
                <vxe-table :data.sync="tableDataRptLogDetail" ref="xTableRptLog" height="400px" :loading="RptLogDetailloading" :sort-config="{ trigger: 'cell' }" show-overflow border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe>
                    <vxe-table-column field="rpt_logid" title="日志明细ID" width="100" sortable header-align="center"></vxe-table-column>
                    <vxe-table-column field="objecttype" title="修改类型" width="100" sortable header-align="center"></vxe-table-column>
                    <vxe-table-column field="columnname" title="修改对象" width="160" sortable header-align="center"></vxe-table-column>
                    <vxe-table-column field="oldvalue" title="修改/复查前取值" width="160" sortable header-align="center"></vxe-table-column>
                    <vxe-table-column field="newvalue" title="修改/复查后取值" width="160" sortable header-align="center"></vxe-table-column>
                </vxe-table>
            </el-dialog>
            <!--导出列选择-->
            <el-dialog title="导出列选择" :visible.sync="chooseColumndialogVisible" width="380px" v-el-drag-dialog :close-on-click-modal="false" v-if="chooseColumndialogVisible">
                <rm-excolsetting :excolPro="excolPro" :allTableCol="allTableCol" @change="saveExportColumn" ref="excolset"></rm-excolsetting>
            </el-dialog>
            <rm-excolsetting :excolPro="excolPro" :allTableCol="allTableCol" @change="saveExportColumn" ref="excolset" v-show="false"></rm-excolsetting>
            <!--多选弹窗--->
            <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
                <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
            </el-dialog>
        </div>
    </div>
</template>

<script>
import { Promise } from "q";
import { invalid } from "moment";
import XE from "xe-utils"; //引入工具类
import RmExcolsetting from "@/components/rmcompents/rm_excolsetting.vue";
XE.mixin({
    // 自定义全局的格式化处理函数
    formatSelect(cellValue, list) {
        return list[cellValue] || cellValue;
    },
});
XE.mixin({
    // 自定义全局的格式化处理函数
    formatSelectList(cellValue, list) {
        // console.log("cellValue",cellValue);
        // console.log("list",list);
        let item = list.find((item) => item.data == cellValue);
        return item ? item.display : "";
    },
});
export default {
    name: "LIS430",
    components: { RmExcolsetting },
    data() {
        return {
            datetime1: "",
            datetime2: "",
            patno: "",
            reqstat: [],
            daterpt: "",
            barcode: "",
            patname: "",
            reqgroup: "",
            //rptunit: "",
            sel_rptunitlist:"",
            reqitem: "",
            pattype: "",
            reqdoc: "",
            sampleno: "",
            reqdeptno: "",
            transid: "",
            reqwardno: "",
            hospcode: "",
            prerptdt1: "",
            prerptdt2: "",
            peformedeptno: "",
            specimencode: "",
            sourceflag: [],
            txtlabgoup: "",
            bedno:"",
            reqgrouprepair: false,
            reqstatOption2: [
                [
                    { value: "1", label: "送出未接收", chk: "0" },
                    { value: "2", label: "送达未接收", chk: "0" },
                    { value: "3", label: "已接收", chk: "0" },
                    { value: "4", label: "未工作组签收", chk: "0" },
                ],
                [
                    { value: "5", label: "工作组签收", chk: "0" },
                    { value: "6", label: "未上机", chk: "0" },
                    { value: "7", label: "已上机", chk: "0" },
                    { value: "8", label: "上机未报告", chk: "0" },
                ],
                [
                    { value: "9", label: "已出报告", chk: "0" },
                    { value: "10", label: "未出报告", chk: "0" },
                ],
            ],
            emeroptions: [
                { label: "", value: 0 },
                { label: "急", value: 1 },
            ],
            sexoptions: {
                1: "男",
                2: "女",
                3: "未判定",
            },
            StatusOption: {
                0: "开单",
                "01": "已审核",
                "02": "审核未通过",
                "03": "复审通过",
                "04": "复审不通过",
                1: "打印/执行",
                15: "打印需重新采样通知单",
                16: "打印报告延时通知单",
                2: "采样",
                "-2": "取消采样",
                3: "送出",
                "-3": "申请信息修改",
                35: "标本送达",
                4: "接收",
                41: "工作组接收",
                42: "上机检验",
                43: "组内交接",
                44: "已分样",
                45: "外送送出",
                46: "前处理分管",
                49: "报告延时发放",
                5: "部分报告",
                6: "确认报告",
                7: "召回报告",
                8: "剔回",
                9: "作废/取消",
            },
            reqstatOption: [],
            userOption: [],
            hospOption: [],
            labgroupOption: [],
            reqstatOptiontable: [],
            tableData: [],
            loading: false,
            tableDatareq: [],
            loadingreq: false,
            tableDatalog: [],
            loadinglog: false,
            showstat: "",
            pattypes: [],
            OtherShow: false,
            Counts: 0,
            barcodestyle: "",
            option: {},
            dialogExport: false,
            datename: "生成日期",
            //  Delay: { hour: "", content: "" },
            dialogRptDelay: false,
            delay: { barcodes: "", delaykey: 0 },
            selrow: {},
            //报告日志详细内容
            tableDataRptLogDetail: [],
            dialogDetailVisible: false,
            RptLogDetailloading: false,
            //混样报告数据
            showmix: false,
            tableDataMix: [],
            loadingmix: false,
            tabvalue: "1",
            //别名
            AliasTableColumn: [],
            queryOption: {},
            custom1alias: "自定义1",
            custom2alias: "自定义1",
            custom3alias: "自定义1",
            custom4alias: "自定义1",
            custom5alias: "自定义1",
            custom6alias: "自定义1",
            custom7alias: "自定义1",
            custom8alias: "自定义1",
            custom9alias: "自定义1",
            custom10alias: "自定义1",
            patothno1alias: "病人编号1",
            patothno1alias: "病人编号2",
            patothno1alias: "病人编号3",
            //导出
            excolPro: "lis430",
            allTableCol: [],
            chooseColumndialogVisible: false,
            option1: [],
            option2: [],
            fieldname: "",
            multichktitle: "",
            dialogMultipleVisible: false,
            reqgroupOption: "",
            reqitemOption: "",
            printcount:"",
            reqdocname: "",
            specimenname: "",
            reqdeptname: "",
            reqwardname: "",
            labgroupname: "",
            hospname: "",
            peformedeptname: "",
            rptunitname: "",
            statusOptions: [],
        };
    },
    created() {
        this.InitOption();
        this.initformatOption();
        this.InitPageData();
    },
    mounted() {
		this.$refs.excolset.colSettingToDB();
	},
    updated() {},
    methods: {
        popMultipleChk(e, fieldname, option, title) {
            let temp = XE.clone(option, true);
            this.option1 = [];
            this.option2 = [];
            if (e != "") {
                let k = e.split(",");
                k.forEach((item) => {
                    let ndata = temp.find((m) => m.data == item);
                    if (ndata != undefined && ndata != null) {
                        this.option2.push(ndata);
                    }
                });
                temp.forEach((item) => {
                    if (k.indexOf(item.data + "") < 0) {
                        this.option1.push(item);
                    }
                });
            } else {
                this.option1 = temp;
            }
            this.fieldname = fieldname;
            this.multichktitle = title;
            this.dialogMultipleVisible = true;
        },
        closedialog(value, name) {
            if (value != "close") {
                this[name] = value;
            }
            this.dialogMultipleVisible = false;
        },
        InitPageData() {
            this.QueryTime();
        },
        DataSelect({ row, rowIndex }) {
            this.selrow = row;
            console.log("🤣 ~ this.selrow ", this.selrow);
            this.QueryReq(row.barcode);
            this.QueryLog(row.barcode);
            this.QueryMix(row.barcode);
        },
        handselect(e, val, name) {
            this.showstat = "";

            this.reqstatOption2.forEach(element => {
                for (let i = 0; i < this.sourceflag.length; i++) {
                    if (element.filter((item) => item.value == this.sourceflag[i]).length > 0) {
                        this.showstat += element.filter((item) => item.value == this.sourceflag[i])[0].label + ",";
                    }
                }
            });
            this.reqstatOption.forEach(element => {
                for (let i = 0; i < this.reqstat.length; i++) {
                    if (element.filter((item) => item.data == this.reqstat[i]).length > 0) {
                        this.showstat += element.filter((item) => item.data == this.reqstat[i])[0].display + ',';
                    }
                }
            });

            if(this.showstat.endsWith(',')){
                this.showstat = this.showstat.substring(0, this.showstat.length-1);
            }
        },
        clear() {
            this.reqstat = [];
            this.sourceflag = [];
            this.showstat = "";
        },
        InitOption() {
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS430",
                    method: "post",
                    data: {
                        action: "InitOption",
                    },
                })
                .then((res) => {
                    this.reqgroupOption = res.reqgroupOption;
                    this.reqitemOption = res.reqitemOption;
                    this.barcodestyle = res.barcodestyle;
                    this.statusOptions = res.statusOptions;
                    this.option = JSON.parse(res.option);
                    if (res.reqstat) {
                        let temp = [];
                        res.reqstat.forEach((item, index) => {
                            this.reqstatOptiontable.push(item);
                            if (index % 4 == 0) {
                                if (temp.length > 0) {
                                    this.reqstatOption.push(temp);
                                    temp = [];
                                    temp.push(item);
                                } else {
                                    temp.push(item);
                                }
                            } else {
                                if (index == res.reqstat.length - 1) {
                                    temp.push(item);
                                    this.reqstatOption.push(temp);
                                } else {
                                    temp.push(item);
                                }
                            }
                        });
                        this.reqstatOptiontable.push({ data: "报告日志", display: "报告日志", inputcode: "BGRZ" });
                        this.reqstatOptiontable.push({ data: "-43", display: "无纸化", inputcode: "WZH" });
                        this.reqstatOptiontable.push({ data: "无纸化", display: "无纸化", inputcode: "WZH" });
                        console.log(this.reqstatOptiontable);
                    }
                })
                .catch((err) => {});
        },
        //  报告延迟封装为组件 
        //增加报告延迟功能
        btnRptDelay() {
            let data = this.$refs.table.getSelectRecords();
            if (data.length == 0) {
                this.$alert("请勾选要延迟报告的标本！", "提示");
                return false;
            } else {
                //this.dialogRptDelay = true;
                //  if (this.$refs.refhour)
                //     setTimeout(() => {
                //         this.$refs.refhour.focus();
                //     }, 10);
                // this.Delay.hour = "";
                // this.Delay.content = "";
                //console.log(this.$refs.refrptdelay);

                this.delay.barcodes = "";
                data.forEach((item) => {
                    this.delay.barcodes += item.barcode + ",";
                });
                this.delay.delaykey++;
                this.dialogRptDelay = true;
            }
        },
        RptDelayChange(flag, msg) {
            if (flag == "1") {
                this.$alert("更新成功，共计更新" + msg + "条数据！", "提示").then(() => {
                    this.QueryReq(this.selrow.barcode);
                    this.QueryLog(this.selrow.barcode);
                    this.QueryMix(this.selrow.barcode);
                    this.dialogRptDelay = false;
                });
            } else if (flag == "close") {
                this.dialogRptDelay = false;
            } else {
                this.$alert(msg, "提示");
            }
        },
        // 增加报告延迟功能
        // RptDelaySave() {
        //     let data = this.$refs.table.getSelectRecords();
        //     if (this.Delay.hour == "") {
        //         this.$alert("请填写正确的延迟时间！", "提示");
        //         return false;
        //     }
        //     if (this.Delay.content == "") {
        //         this.$alert("请填写延迟原因！", "提示");
        //         return false;
        //     }
        //     let barcodes = "";
        //     data.forEach((item) => {
        //         barcodes += item.barcode + ",";
        //     });
        //     this.$tool
        //         .request({
        //             url: "LIS/LIS4/LIS430",
        //             method: "post",
        //             data: {
        //                 action: "RptDelaySave",
        //                 barcodes: barcodes,
        //                 ...this.Delay,
        //             },
        //         })
        //         .then((res) => {
        //             if (res.errcode == "1") {
        //                 this.$alert("更新成功，共计更新" + data.length + "条数据！", "提示").then(() => {
        //                     this.dialogRptDelay = false;
        //                     this.QueryReq(this.selrow.barcode);
        //                     this.QueryLog(this.selrow.barcode);
        //                 });
        //             } else {
        //                 this.$alert(res.errmsg, "提示");
        //             }
        //         })
        //         .catch((e) => {});
        // },
        async initformatOption() {
            try {
                const res = await this.$tool.request({
                    url: "LIS/LIS6/LIS610",
                    method: "post",
                    data: {
                        action: "initOption",
                    },
                });
                this.userOption = res.userOption;
                this.hospOption = res.hospOption;
                this.labgroupOption = res.labgroupOption;
            } catch (e) {
                this.$message.warning(e);
            }
        },
        //添加导出列
        setExportColumn() {
            let allColumnList = [];
            this.$refs.table.getColumns().forEach((element) => {
                if (element.property) {
                    allColumnList.push({
                        title: element.title,
                        property: element.property,
                    });
                }
            });
            this.allTableCol = allColumnList;
            this.chooseColumndialogVisible = true;
        },
        saveExportColumn() {
            this.chooseColumndialogVisible = false;
        },
        // code转name
        formatFun({ cellValue, column, row }) {
            if (["create_user", "print_user", "sampled_user", "recieve_user", "send_user", "charge_user", "test_user", "send_user1", "cancel_user", "discard_user", "reject_user"].includes(column.property)) {
                try {
                    let username = this.userOption.find((m) => m.data == cellValue);
                    if (username != undefined && username != null) {
                        return username.display;
                    } else {
                        return cellValue;
                    }
                } catch {}
            } else if (["hospcode", "pat_hospcode"].includes(column.property)) {
                try {
                    let hospname = this.hospOption.find((m) => m.data == cellValue);
                    if (hospname != undefined && hospname != null) {
                        return hospname.display;
                    } else {
                        return cellValue;
                    }
                } catch {}
            }
            // } else if (["reqsource"].includes(column.property)) {
            //     try {
            //         let reqsourcename = this.$opt.reqsourceOptions.find((m) =>XE.tostring( m.value) == XE.tostring(cellValue));
            //         if (reqsourcename != undefined && reqsourcename != null) {
            //             return reqsourcename.label;
            //         } else {
            //             return cellValue;
            //         }
            //     } catch {}
            // }else if (["reqtype"].includes(column.property)) {
            //     try {
            //         let reqtypename =  this.$opt.reqtypeOptions.find((m) => m.value == cellValue);
            //         if (reqtypename != undefined && reqtypename != null) {
            //             return reqtypename.label;
            //         } else {
            //             return cellValue;
            //         }
            //     } catch {}
            //  }else if (["labgroup"].includes(column.property)) {
            //     try {
            //         let labgroupname =  this.$opt.labgroupOptions.find((m) => m.value == cellValue);
            //         if (labgroupname != undefined && labgroupname != null) {
            //             return labgroupname.label;
            //         } else {
            //             return cellValue;
            //         }
            //     } catch {}
            // }
        },
        QueryTime() {
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS430",
                    method: "post",
                    data: {
                        action: "InitData",
                    },
                })
                .then((res) => {
                    if (res) {
                        this.datetime1 = XE.clone(res.now, true) + " 00:00:00";
                        this.datetime2 = XE.clone(res.now, true) + " 23:59:59";
                        this.pattypes = res.pattype;
                    }
                })
                .catch((err) => {
                    this.loadingreq = false;
                });
        },
        QueryMainthen() {
            this.QueryMain()
                .then(() => {
                    if (this.barcode.length > 0) {
                        this.$refs.barcode.select();
                    }
                    if (this.tableData.length > 0) {
                        this.$nextTick(() => {
                            this.$refs.table.setCurrentRow(this.tableData[0]);
                            this.selrow = this.tableData[0];
                            this.QueryReq(this.tableData[0].barcode);
                            this.QueryLog(this.tableData[0].barcode);
                            this.QueryMix(this.tableData[0].barcode);
                        });
                    } else {
                        this.tableDatareq = [];
                        this.tableDatalog = [];
                    }
                })
                .catch(() => {
                    this.tableDatareq = "";
                    this.tableDatalog = "";
                });
        },
        //获取别名
        setAlias() {
            this.AliasTableColumn = [];
            for (var i = 1; i < 11; i++) {
                this["custom" + i + "alias"] = this.queryOption["CUSTOM" + i + "ALIAS"] && this.queryOption["CUSTOM" + i + "ALIAS"] != "" ? this.queryOption["CUSTOM" + i + "ALIAS"] : "自定义" + i;
                var p = {
                    title: this["custom" + i + "alias"],
                    field: "custom" + i,
                    width: 100,
                };
                this.AliasTableColumn.push(p);
            }
            for (var i = 1; i < 4; i++) {
                this["patothno" + i + "alias"] = this.queryOption["PATOTHNO" + i + "ALIAS"] && this.queryOption["PATOTHNO" + i + "ALIAS"] != "" ? this.queryOption["PATOTHNO" + i + "ALIAS"] : "病人编号" + i;
                var p = {
                    title: this["patothno" + i + "alias"],
                    field: "pat_othno" + i,
                    width: 100,
                };
                this.AliasTableColumn.push(p);
            }
        },
        FormatData({ cellValue, row, column }){
            if (column.property == "req_stat") {
                try {
                    if (row.req_stat != "") {
                        return this.statusOptions.find((m) => m.value == row.req_stat).label;
                    } else {
                        return cellValue;
                    }
                } catch (e) {
                    return cellValue;
                }
            }
        },
        cellClassName({ column, row, columnIndex }) {
            if (column.property == "req_stat") {
                return this.$pub.getreqstatclass(row.req_stat);
            } else {
                return "";
            }
        },
        QueryMain() {
            var _this = this;
            return new Promise((s, f) => {
                _this.tableData = [];
                _this.tableDatareq = [];
                _this.tableDatalog = [];
                _this.loading = true;

                var sec_reqstat = '';
                var sec_sourceflag = '';
                if(_this.reqstat.length > 0){
                    for (let i = 0; i < _this.reqstat.length; i++) {
                        sec_reqstat += _this.reqstat[i] + ',';
                    }
                }
                if(_this.sourceflag.length > 0){
                    for (let i = 0; i < _this.sourceflag.length; i++) {
                        sec_sourceflag += _this.sourceflag[i] + ',';
                    }
                }
                if(sec_reqstat.endsWith(',')){
                    sec_reqstat = sec_reqstat.substring(0, sec_reqstat.length-1);
                }
                if(sec_sourceflag.endsWith(',')){
                    sec_sourceflag = sec_sourceflag.substring(0, sec_sourceflag.length-1);
                }

                _this.$tool
                    .request({
                        url: "LIS/LIS4/LIS430",
                        method: "post",
                        data: {
                            action: "query",
                            flag: sec_sourceflag,
                            barcode: _this.barcode,
                            patno: _this.patno,
                            reqstat: sec_reqstat,
                            datetime1: _this.datetime1,
                            datetime2: _this.datetime2,
                            daterpt: _this.daterpt,
                            patname: _this.patname,
                            reqgroup: _this.reqgroup,
                            //rptunit: _this.rptunit,
                            sel_rptunitlist: _this.sel_rptunitlist,
                            reqitem: _this.reqitem,
                            pattype: _this.pattype,
                            reqdoc: _this.reqdoc,
                            sampleno: _this.sampleno,
                            reqdeptno: _this.reqdeptno,
                            transid: _this.transid,
                            reqwardno: _this.reqwardno,
                            hospcode: _this.hospcode,
                            prerptdt1: _this.prerptdt1,
                            prerptdt2: _this.prerptdt2,
                            peformedeptno: _this.peformedeptno,
                            bedno:_this.bedno,
                            specimencode: _this.specimencode,
                            txtlabgoup: _this.txtlabgoup,
                            datename: _this.datename == "生成日期" ? "1" : "2",
                            printcount: _this.printcount,
                        },
                    })
                    .then((res) => {
                        if (res.errcode == "1") {
                            this.queryOption = res.queryOption;
                            this.setAlias();
                            _this.tableData = res.RData.Data;
                            _this.Counts = res.num;
                            if (res.num > 5000) {
                                _this.$message.info("数据超过5000条,仅显示前5000条", "提示");
                            }
                            _this.loading = false;
                            if (res.hasOwnProperty("sqlstr") && res.sqlstr) {
                                _this.$pub.Log("LIS430 查询:" + res.sqlstr);
                            }
                            s();
                        } else {
                            _this.$alert(res.errmsg, "提示");
                            f();
                        }
                    })
                    .catch((err) => {
                        _this.loading = false;
                        _this.$message.info("数据过多连接超时!请加入筛选条件后尝试!", "提示");
                        f();
                    });
            });
        },
        QueryReq(barcode) {
            this.loadingreq = true;
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS430",
                    method: "post",
                    data: {
                        action: "queryreqitem",
                        barcode: barcode,
                    },
                })
                .then((res) => {
                    this.tableDatareq = res.Data;
                    this.loadingreq = false;
                })
                .catch((err) => {
                    this.loadingreq = false;
                });
        },
        QueryLog(barcode) {
            this.loadinglog = true;
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS430",
                    method: "post",
                    data: {
                        action: "querylog",
                        barcode: barcode,
                    },
                })
                .then((res) => {
                    this.tableDatalog = this.DealLog(res);
                    this.loadinglog = false;
                })
                .catch((err) => {
                    this.loadinglog = false;
                });
        },
        DealLog(res) {
            var data = res.Data.Data;
            var rptlogdt = res.reportlogdt;
            var bactlogdt = res.bactlogdt;
            var redata = [];
            for (let i = 0; i < data.length; i++) {
                if (data[i].reportid) {
                    var children = rptlogdt.filter((item) => item.reportid == data[i].reportid);
                    if (children.length > 0) data[i].children = children;
                }
                if(data[i].sampleid && data[i].trans_type=='-43'){
                    if(bactlogdt && bactlogdt.length>0){
                        data[i].children = bactlogdt;
                    }
                }
                redata.push(data[i]);
            }
            // console.log("redata",redata);
            return redata;
        },
        //补打条码
        RePrintBarcode(barcode) {
            if (barcode && barcode != "") {
                if (!this.barcodestyle || this.barcodestyle == "") {
                    this.$alert("没有维护条码样式!", "提示");
                } else {
                    this.$pub.printbarcode(this, barcode, "1", this.barcodestyle, "");
                }
            }
        },
        Reprint() {
            //let row = this.$refs.table.getCurrentRow();
            // if (row) {
            //     this.RePrintBarcode(row.barcode);
            // } else {
            //     this.$alert("请选择要补打的条码!", "提示");
            // }
            //补打条码改为批量打印，注意打印顺序
            let that = this;
            let datas = that.$refs.table.getSelectRecords();
            let barcodes = [];
            datas.forEach((item) => {
                barcodes.push(item.barcode);
            });
            let printdata = this.$refs.table.afterFullData.filter((item) => barcodes.indexOf(item.barcode) > -1);
            setTimeout(() => {
                that.PrintLoopFun(that, printdata, 0);
            }, 100);
        }, //补打条码改为批量打印，注意打印顺序
        PrintLoopFun(that, datas, printindex) {
            that.PrintFun(that, datas, printindex).finally((e) => {
                printindex++;
                if (printindex < datas.length) {
                    setTimeout(() => {
                        that.PrintLoopFun(that, datas, printindex);
                    }, 100);
                }
                // this.$pub.Log("PrintFun - end");
            });
        }, //补打条码改为批量打印，注意打印顺序
        async PrintFun(that, datas, printindex) {
            that.RePrintBarcode(datas[printindex].barcode);
        },

        BtnReadCard() {
            if (typeof jsObj != "undefined") {
                this.patno = jsObj.ReadCard(this.option.READCARDCMDLINE);
                //this.patno = "123";
                if (this.patno == "") {
                    return false;
                }
                this.$tool
                    .request({
                        url: "LIS/LIS4/LIS430",
                        method: "post",
                        data: {
                            action: "readcard",
                            patno: this.patno,
                        },
                    })
                    .then((res) => {
                        if (res && res.hasOwnProperty("showpatno")) {
                            this.patno = res.showpatno;
                            this.QueryMain();
                        }
                    })
                    .catch((err) => {});
            } else {
                this.$alert("请使用" + this.$pub.clientname + "打开系统", "错误", {
                    confirmButtonText: "确定",
                });
            }
        },
        //导出列选择
        btnExport() {
            let extableColumn = [];
            this.$refs.refdialogExport
                .ShowDialog()
                .then(() => {
                    // let tableColumn = this.$refs.table.getColumns();
                    // tableColumn.forEach((item) => {
                    //     extableColumn.push({ title: item.title, field: item.property });
                    // });
                    var rightlocalStorage = JSON.parse(window.localStorage.getItem(this.excolPro + "exportCol"));
                    let tableColumn = this.$refs.table.getColumns();
                    let exportColumn = [];
                    if (rightlocalStorage && rightlocalStorage.length > 0) {
                        rightlocalStorage.forEach((item) => {
                            exportColumn.push({
                                title: item.extitle ? item.extitle : item.title,
                                field: item.property,
                            });
                        });
                    } else {
                        tableColumn.forEach((item) => {
                            exportColumn.push({ title: item.title, field: item.property });
                        });
                    }
                    let filtertxt = this.getExportFilter();
                    this.$pub.exportTableExcel(this.tableData, exportColumn, "LIS430 申请单查询结果.xlsx", filtertxt);
                })
                .catch(() => {
                    let tableColumn = this.$refs.tablereq.getColumns();
                    tableColumn.forEach((item) => {
                        extableColumn.push({ title: item.title, field: item.property });
                    });
                    let filtertxt = "条码号:" + this.selrow.barcode + "; ";
                    this.$pub.exportTableExcel(this.tableDatareq, extableColumn, "LIS430 申请单查询结果明细.xlsx", filtertxt, "申请单明细条件：");
                });
        },
        reqdocChange(code, name) {
            this.reqdoc = code;
            this.reqdocname = name;
        },
        specimenChange(code, name) {
            this.specimencode = code;
            this.specimenname = name;
        },
        reqdeptChange(code, name) {
            this.reqdeptno = code;
            this.reqdeptname =name;
        },
        reqwardChange(code, name) {
            this.reqwardno = code;
            this.reqwardname = name;
        },
        labgroupChange(code, name) {
            this.txtlabgoup = code;
            this.labgroupname = name;
        },
        hospChange(code, name) {
            this.hospcode = code;
            this.hospname = name;
        },
        peformedeptChange(code, name) {
            this.peformedeptno = code;
            this.peformedeptname = name;
        },
        rptunitChange(code, name) {
            this.sel_rptunitlist = code;
            this.rptunitname = name;
        },
        // 获取当前导出文件的所有查询条件
        getExportFilter() {
            let filtertxt = this.datename + ":" + XE.toDateString(this.datetime1, "yyyy-MM-dd HH:mm:ss") + "至" + XE.toDateString(this.datetime2, "yyyy-MM-dd HH:mm:ss") + "; ";
            if(this.barcode) filtertxt += "条码号:" + this.barcode + "; ";
            if(this.patname) filtertxt += "病人姓名:" + this.patname + "; ";
            if(this.pattype) filtertxt += "病人类型:" + this.getOptionName(this.pattypes.filter((item) =>  this.pattype == item.codeno)) + "; ";
            if(this.reqdoc) filtertxt += "申请医生:" + this.reqdocname + "; ";
            if(this.showstat) filtertxt += "申请状态:" + this.showstat + "; ";
            if(this.patno) filtertxt += "病历号:" + this.patno + "; ";
            if(this.reqgroup) filtertxt += "分单类别:" +  this.getOptionName(this.reqgroupOption.filter((item) =>  ("," + this.reqgroup + ",").indexOf("," + item.data + ",") > -1)) + "; ";
            if(this.specimencode) filtertxt += "标本类型:" + this.specimenname + "; ";
            if(this.reqdeptno) filtertxt += "申请科室:" + this.reqdeptname + "; ";
            if(this.reqwardno) filtertxt += "病人病区:" + this.reqwardname + "; ";
            if(this.reqitem) filtertxt += "申请项目:" +  this.getOptionName(this.reqitemOption.filter((item) =>  ("," + this.reqitem + ",").indexOf("," + item.data + ",") > -1)) + "; ";
            if(this.txtlabgoup) filtertxt += "检验工作组:" + this.labgroupname + "; ";
            if(this.hospcode) filtertxt += "送检医院:" + this.hospname + "; ";
            if(this.peformedeptno) filtertxt += "执行科室:" + this.peformedeptname + "; ";
            if(this.bedno) filtertxt += "病人床号:" + this.bedno + "; ";
            let prerptdttxt = "";
            if(this.prerptdt1) prerptdttxt +=  XE.toDateString(this.prerptdt1, "yyyy-MM-dd HH:mm:ss");
            if(this.prerptdt2) prerptdttxt +=  "至" + XE.toDateString(this.prerptdt2, "yyyy-MM-dd HH:mm:ss");
            if(prerptdttxt) filtertxt += "预出报告时间:" + prerptdttxt + "; ";
            if(this.sampleno) filtertxt += "样本号:" + this.sampleno + "; ";
            if(this.daterpt) filtertxt += "报告日期:" + XE.toDateString(this.daterpt, "yyyy-MM-dd") + "; ";
            if(this.sel_rptunitlist) filtertxt += "报告单元多选:" + this.rptunitname + "; ";
            if(this.reqgrouprepair) filtertxt += "检验组修复模式; ";
            if(this.printcount) filtertxt += "打印次数:" + this.printcount + "; ";
            return filtertxt;
        },
        getOptionName(option) {
            if (option && option.length > 0) {
                let optionname = "";
                option.forEach((item) => {
                    if(item.hasOwnProperty("codena")) {
                        optionname += item.codena + ",";
                    } else {
                        optionname += item.display + ",";
                    }
                });
                return optionname.substring(0, optionname.length - 1);
            } else {
                return "";
            }
        },
        exportOperate(flag) {
            if (flag == "1") this.$refs.refdialogExport.Confirm();
            else this.$refs.refdialogExport.Cancel();
        },
        handleCommand(name) {
            this.datename = name;
        },
        QueryLogDetail(logid) {
            this.RptLogDetailloading = true;
            this.$tool
                .request({
                    url: "/ucent/reportlog",
                    method: "post",
                    data: {
                        action: "getReportlogdetail",
                        rpt_logid: logid,
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        this.tableDataRptLogDetail = res.Data;
                    }
                    this.RptLogDetailloading = false;
                });
        },
        LogDblClick({ row, rowIndex }) {
            if (row.hasOwnProperty("rpt_logid")) {
                this.QueryLogDetail(row.rpt_logid);
                this.dialogDetailVisible = true;
            }
        },
        ColumnClassName({ seq, row, rowIndex, $rowIndex, column }) {
            if (column.property == "trans_type") {
                if (row.trans_type == "报告日志" || row.trans_type=="无纸化") return "reportlogclass";
            }
        },
        QueryMix(barcode) {
            this.loadingmix = true;
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS430",
                    method: "post",
                    data: {
                        action: "querymixbarcode",
                        barcode: barcode,
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        if (res.mixdata.length > 0) this.showmix = true;
                        else this.showmix = false;
                        this.tableDataMix = res.mixdata;
                    }
                    this.loadingmix = false;
                })
                .catch((err) => {
                    this.loadingmix = false;
                });
        },
        repalceComputerName(row) {
            this.$pub.getComputerName(row.mac_address)
                .then((name)=> {
                    row.computer_name = name;
                })
                .catch(()=> {
                    this.$message.error("机器名称查询失败！");
                    //保持原样
                });
        },
    },
};
</script>

<style scoped>
::v-deep .vxe-body--row .el-input--small .el-input__inner {
    height: 20px !important;
    line-height: 20px !important;
}
::v-deep .reportlogclass {
    color: blue;
    font-style: italic;
    font-size: 10px;
}
.pagetop {
    left: 0;
    right: 0;
    height: 155px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
    position: absolute;
    z-index: 99;
}

.pagecenter {
    position: absolute;
    top: 160px;
    width: 100%;
    left: 0;
    bottom: 5px;
}

.middle-left {
    position: absolute;
    height: 100%;
    width: 800px;
    left: 0px;
    top: 0;
}

.middle-center {
    position: absolute;
    height: 100%;
    left: 805px;
    right: 0;
    top: 0;
}

table tr td:nth-child(odd) {
    text-align: right;
    white-space: nowrap;
}
table tr td:nth-child(even) {
    text-align: left;
}
table tr td:nth-child(1) {
    width: 80px;
}
.table1style tr td {
    padding: 2px;
}
.table2style tr td {
    padding: 0px 2px 0px 2px;
}
.fixtotal{
    overflow: hidden;
    position: absolute;
    left: 0px;
    bottom: 3%;
    z-index: 1;
    width: 100%;
}
</style>
